// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_SALES_APPROVED_FEE
// * CreateDate    : 2011/11/21 10:37:36
// * Creater       : CodeSmith
// * LastChangeDate: 2011/11/21 10:37:36
// * LastChanger   : 2011/11/21 10:37:36
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;
using ESOL.Common;

namespace ESOL.Business.Sales
{
/// <summary>
    /// SalesApprovedFee
    /// </summary>
    public partial class SalesApprovedFeeBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objSalesApprovedFeeEntity">Entity</param>
        /// <returns>Entity</returns>
        public static SalesApprovedFeeEntity GetSalesApprovedFee(SalesApprovedFeeEntity objSalesApprovedFeeEntity)
        {
            return DataAccess.SelectSingle<SalesApprovedFeeEntity>(objSalesApprovedFeeEntity);
        }
        public static SalesApprovedFeeEntity GetSalesApprovedFeeByID(string feeId)
        {
            if (string.IsNullOrEmpty(feeId))
            {
                return null;
            }
            SalesApprovedFeeEntity entity = new SalesApprovedFeeEntity();
            entity.FeeId = feeId;
            return DataAccess.SelectSingle<SalesApprovedFeeEntity>(entity);
        }
        public static DataTable GetByCondition(string condition, string orderBy, string rowCount)
        {
            string sql = CommonFunctions.GetSelect(rowCount) + @"CONVERT(DECIMAL(18,2),F.APPROVED_AMOUNT) AS APPROVED_AMOUNT,
							F.*, C.CUSTOMER_NAME, P.NAME_CN
                            FROM SALES_APPROVED_FEE F
                            LEFT JOIN MST_CUSTOMER C ON C.CUSTOMER_ID = F.CUSTOMER_ID
                            LEFT JOIN MST_PERSON P ON P.PERSON_ID = F.PERSON_ID
                            WHERE 1=1 ";
            if (string.IsNullOrEmpty(condition) == false)
            {
                sql += condition;
            }
            if (string.IsNullOrEmpty(orderBy) == false)
            {
                sql += " ORDER BY " + orderBy;
            }
            DataSet ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objSalesApprovedFeeEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertSalesApprovedFee(SalesApprovedFeeEntity objSalesApprovedFeeEntity)
        {
            return DataAccess.Insert(objSalesApprovedFeeEntity);
        }

        public static bool InsertSalesApprovedFee(List<SalesApprovedFeeEntity> objSalesApprovedFeeEntityList)
        {
            return DataAccess.Insert(objSalesApprovedFeeEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objSalesApprovedFeeEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateSalesApprovedFee(SalesApprovedFeeEntity objSalesApprovedFeeEntity)
        {
            return DataAccess.Update(objSalesApprovedFeeEntity);
        }

        public static bool UpdateSalesApprovedFee(List<SalesApprovedFeeEntity> objSalesApprovedFeeEntityList)
        {
            return DataAccess.Update<SalesApprovedFeeEntity>(objSalesApprovedFeeEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objSalesApprovedFeeEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteSalesApprovedFee(SalesApprovedFeeEntity objSalesApprovedFeeEntity)
        {
            return DataAccess.Delete(objSalesApprovedFeeEntity);
        }

        public static bool DeleteSalesApprovedFee(List<SalesApprovedFeeEntity> objSalesApprovedFeeEntityList)
        {
            return DataAccess.Delete<SalesApprovedFeeEntity>(objSalesApprovedFeeEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetSalesApprovedFeeAll()
        {
            return DataAccess.SelectAllDataSet<SalesApprovedFeeEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<SalesApprovedFeeEntity> GetSalesApprovedFeeAllList()
        {
            return DataAccess.SelectAll<SalesApprovedFeeEntity>();
        }
        #endregion
	}
	
	
}	

